Repository navigation
PP-0: code standards with a shrink-only baseline; one atomic writer, one grammar helper - #65
Merged
Merged
Conversation
…nd one grammar helper Tooling (spec revision 4, section 9): - tools/code_rules.py is the shared file from MorphoFeature, extended with the private-docstring rule, the layer check (pure/io/ui/orchestration, declared per module in pyproject.toml), RESERVED_NAMES (shared logic may only be defined by its owner repository), a baseline that may only shrink, and a ratchet on the # noqa count of C901/PLR0913/PLR0915/ANN. The SHA-256 test keeps the copy identical. - tools/check.py runs ruff, pytest and the code rules. Its --rules flag runs the rules alone (CI lint job); --update-baseline only lowers the baseline, never raises it. - Ruff now selects C90 (15), PLR0913 (8), PLR0915 (50) and ANN. The 63 existing ANN sites in src/tools, two of each other rule in src and one PLR0913 in tests carry # noqa, counted by the ratchet. Tests are exempt from ANN, as from D. The experiments scripts are exempt as run. - tools/code_rules_baseline.json records the 110 violations that existed. - Guard fixtures prove each rule fires. Dedup with no behaviour change (plan-structure audit D1, D7): - _io.write_text_atomic replaces the three copies in design.py, manifest.py and mask_scan.py. - validation.agree replaces _are/_contain (discovery.py) and _do/_their/_are/_match/_have (masks.py). Docs: development.md "Code standards", AGENTS.md "Done means". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
PP-0 now merges after #64 (PP-1). Its baseline covers the combined code, so main stays green whichever PR is reviewed first. It adds layers for #64's modules: axis_check and mask_checks are pure, notebook_axes is ui. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
The baseline is regenerated on the new main: the review commit 5f9b015 adds a line to axes.py. PP-0 creates the baseline, so it records main as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
This was referenced Nov 1, 2026
…es, the future import - A bare `# noqa` or `# ruff: noqa` hid every Ruff rule from the noqa ratchet. Ruff now selects PGH004, and the ratchet also counts file-level `ruff: noqa:` codes and the `# noqa` comments in tests (one existing PLR0913 in tests/zarr_tree.py is now counted). - `baseline_key` took the first number of a message as its size, which for identical bodies was a line number: moving a duplicated helper down failed as "grew". A line number or a digit inside a name is no longer a size; those entries lower to 0. - Spec §9 asks for `from __future__ import annotations`; I002 now enforces it in src and tools (added to `__init__` and `__main__`; tests, experiments and notebooks exempt). The shared file's SHA-256 in the identity test is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a
Contributor
Author
|
Independent review: approved after one fix commit ( Checked
Fixed in
Follow-ups (not blocking)
Gate on
Generated by Claude Code |
guijacquemet
marked this pull request as ready for review
November 1, 2026 17:07
guijacquemet
pushed a commit
that referenced
this pull request
Nov 3, 2026
Normalization main 534c63d (#65, issue #47) refuses a PlaneHistogram with valid pixels and no pixel_min or pixel_max. The test now passes them from the version-2 columns; it passes with v0.3.3 (still the pin) and 534c63d. It is the only PlaneHistogram construction in src/ and tests/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PP-0 of the v0.4.0 plan (
preprocessing-design-v0.4.mdrevision 4, §8 and §9): tooling and dedup, with no behaviour change. Its own diff adds tooling, dedup and a baseline; it changes no behaviour.Merge order: #64 (PP-1, merged) is already in this branch (
1fa7ccb), so the baseline covers the combined code.Summary
tools/code_rules.py: the shared file copied from MorphoFeatureorigin/main(9951a58), extended with §9:pure,io,uiororchestrationinpyproject.toml. Pure modules may not import I/O or UI modules, or callopen,print,read_textand the like; UI modules may not importscipy;RESERVED_NAMES: shared logic listed by its owner repository (normalization, preprocessing, CellPatcher). A definition anywhere else fails;baseline_keydrops line numbers, so code that moves keeps its entry. New or grown violations fail, and so do entries the code no longer needs;# noqacount ratchet for C901, PLR0913, PLR0915 and ANN, counting line and file-level (ruff: noqa:) comments in src, tools and tests.tools/check.py: runs ruff, pytest and the code rules.--rulesruns only the code rules; the CI lint job runs it.--update-baselineonly lowers the baseline.noqamust name its rules) and I002 (from __future__ import annotationsin every module of src and tools).# noqa, counted by the ratchet: 63 ANN, 2 C901, 3 PLR0913 (one intests/zarr_tree.py) and 2 PLR0915.noqa:planes._tiff_blocking'skeyframe, and the notebook's Step 0 function.tools/code_rules_baseline.json: the 113 violations present in PP-1: the axis check (swaps and contradictions are errors; plain stacks confirmed) #64 + main (oversized files and functions, private functions without docstrings, duplicated test helpers)._io.write_text_atomicreplaces the three temp-file-then-os.replacecopies (design.py,manifest.py,mask_scan.py);validation.agreereplaces_are/_contain(discovery) and_do/_their/_are/_match/_have(masks).development.md; AGENTS.md "Done means" now refers totools/check.py.Review fixes (
0608025)# noqaor# ruff: noqa: …hid rules from the ratchet (both passed--rules). Now PGH004 refuses the bare form, and file-level codes and tests' comments are counted.baseline_keyused the first number of an "identical bodies" message, a line number, as its size: moving a duplicated helper down failed as "grew". Line numbers and digits inside names are no longer sizes; those four entries are lowered to 0.from __future__ import annotationswas not enforced; I002 now does (added to__init__.pyand__main__.py).Notes for review
origin/main's baseline in CI.Tests
tests/test_code_rules.py(18): the shared-file SHA; the repository against its baseline; every module has a layer; ruff guards for ANN001, C901, PLR0913, PGH004 and I002; size and suppress guards; private docstrings; layers; reserved names; the baseline's shrink and grow rules; line numbers are never sizes; line and file-level noqa counts.tests/test_shared_helpers.py(4):write_text_atomicandagree.tools/,_ioandagreedo not exist.tools/check.py --rules, pytest with.[dev,notebook,zarr]):🤖 Generated with Claude Code
https://claude.ai/code/session_01WX6rdMV1r5jUPUR94kxV5a